package cn.ruituo.adv8.client;
import java.io.*;
import java.net.*;
public class GetFile {
    public static void main(String[] args) {
        Socket s=null;
        try {
            s=new Socket("192.168.1.131",8882);
            OutputStream os=s.getOutputStream();
            InputStream is=s.getInputStream();
            String st="jixue.jpg\r\n";
            os.write(st.getBytes());
            os.flush();

            FileOutputStream fis=new FileOutputStream("e:\\jixue.jpg");
            int a=0;
            byte[] bytes=new byte[1024];
            // System.out.println(is.available());
            int total=0;
            while ((a=is.read(bytes))!=-1){
                fis.write(bytes,0,a);
                System.out.println("get "+a);
                total+=a;
            }
            System.out.println("接受完毕"+total);
            fis.close();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                s.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
